import { request } from '@/common/js/request.js'

// 手机号 + 密码登陆
export function login(mobile, password) {
  return request({
    url: '/app-api/member/login',
    method: 'post',
    data: {
		mobile, password
	}
  })
}

// 手机号 + 验证码登陆
export function smsLogin(mobile, code) {
  return request({
    url: '/app-api/member/sms-login',
    method: 'post',
    data: {
		mobile, code
	}
  })
}

// 发送手机验证码
export function sendSmsCode(mobile, scene) {
	return request({
	  url: '/app-api/member/send-sms-code',
	  method: 'post',
	  data: {
			mobile, scene
		}
	})
}

// 获取验证码
export function getCodeImg() {
	return request({
	  url: '/admin-api/system/captcha/get-image',
	  method: 'get',
	  timeout: 20000
	})
 
}


// 退出
export function logout() {
	return request({
	  url: '/admin-api/member/logout',
	  method: 'get',
	  timeout: 20000
	})
 
}

import store from '@/store'
export function logoutStore() {
	store.commit('logout');
	store.dispatch('LogOut').then(() => {
	  // 登录页面不需重新加载
	  if (window.location.hash.indexOf("#/login") !== 0) {
	    location.href = '/index';
	  }
	})
 
}

/* // UI调用
import store from '@/store'
logout()
.then(data => {
	
	store.commit('logout');
	store.dispatch('LogOut').then(() => {
	  // 登录页面不需重新加载
	  if (window.location.hash.indexOf("#/login") !== 0) {
	    location.href = '/index';
	  }
	})
})
.catch(errors => {	
}).finally(() => {
}) */